package cn.springsoter.core.log4j2.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import cn.springsoter.core.log4j2.filter.LogMDCFilter;

/**
 * 
 * @author kevin
 *
 */
@Configuration
public class LogConfig {
	@Bean
    public FilterRegistrationBean logMDCFilter() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();

        LogMDCFilter logMDCFilter = new LogMDCFilter();

        filterRegistrationBean.setFilter(logMDCFilter);
        filterRegistrationBean.addUrlPatterns("/*");//配置过滤规则
        filterRegistrationBean.setName("LogMDCFilter");//设置过滤器名称
        filterRegistrationBean.setOrder(0);//执行次序

        return filterRegistrationBean;
    }
}
